<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="./libs/react.js"></script>
    <script src="./libs/react-dom.js"></script>
    <script src="./libs/babel.min.js"></script>
    <script type="text/babel">
      const { Component } = React;
      class App extends Component {
        constructor(props) {
          super(props);
          this.state = {
            name: "",
            desc: "",
            skills: "",
          };
          this.keyUpHandle = this.keyUpHandle.bind(this);
        }
        keyUpHandle(e) {
          const obj = {};
          obj[e.target.dataset.id] = e.target.value;
          this.setState(obj);
        }
        render() {
          return (
            <div>
              <ul>
                <li>
                  <input
                    onKeyUp={this.keyUpHandle}
                    data-id="name"
                    type="text"
                    placeholder="请输入名字"
                  />
                </li>
                <li>
                  <input
                    onKeyUp={this.keyUpHandle}
                    data-id="desc"
                    type="text"
                    placeholder="请输入个人简介"
                  />
                </li>
                <li>
                  <input
                    onKeyUp={this.keyUpHandle}
                    data-id="skills"
                    type="text"
                    placeholder="请输入技能"
                  />
                </li>
              </ul>
              <button
                onClick={() => {
                  console.log(this.state);
                }}
              >
                提交
              </button>
            </div>
          );
        }
      }
      ReactDOM.render(<App />, document.getElementById("app"));
    </script>
  </body>
</html>
